<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- <meta name="referrer" content="never"> -->
    <title>Document</title>
    <script src="../application/vue.js"></script>
    <style>
        img{
            width:300px;
            height:300px;
            border:1px solid black;
            background-color:rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <div id="app">
        <img v-preload:cover="img1">
        <!-- <p v-preload="msg">{{msg}}</p>
        <input type="text" v-model="msg"> -->
    </div>
</body>
<script>
    var vm= new Vue({
        el:"#app",
        data:{
            msg:"变量",
            img1:"http://img4.imgtn.bdimg.com/it/u=1878125254,116198046&fm=11&gp=0.jpg"
        },
        directives:{
            preload(el,binding,newVnode,oldVnode){
                // console.log(el,binding,newVnode,oldVnode);
                el.src="../image/5-121204193935-51.gif";
                el.style.objectFit="none";
                el.style.objectPosition="center";
                let img=new Image();
                img.src=binding.value;
                img.onload=function(){
                    el.src=binding.value;
                    el.style.objectFit=binding.arg;
                }
                // el.textContent=binding.value;
                // console.log(newVnode,oldVnode);
            }
        }
    })
</script>
</html>